//
//  YPPasswordManageViewController.m
//  ChengHuiTong
//
//  Created by KiVen on 15/12/1.
//  Copyright © 2015年 张文权. All rights reserved.
//

#import "YPPasswordManageViewController.h"
#import "SetPassWordViewController.h"
#import "CLLockVC.h"
#import "YPForgotPasswordViewController.h"

@interface YPPasswordManageViewController ()<UITableViewDataSource,UITableViewDelegate>{
    
    NSArray * _titleArray;

    UITableView *_passwordManageTableView;

}

@end

@implementation YPPasswordManageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"密码管理";
//,@"设置交易密码"
    _titleArray = @[@"修改手势密码",@"修改登录密码",@"设置交易密码"];

    _passwordManageTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) style:UITableViewStyleGrouped];
    _passwordManageTableView.dataSource = self;
    _passwordManageTableView.delegate = self;
    _passwordManageTableView.contentInset = UIEdgeInsetsMake(-20, 0, 0, 0);
    _passwordManageTableView.sectionHeaderHeight =15.0f;
    _passwordManageTableView.sectionFooterHeight = 0.0f;
    _passwordManageTableView.backgroundColor = kColor_AppBaseBackground;

    [self.view addSubview:_passwordManageTableView];

}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:YES];
    [MobClick beginLogPageView:@"密码管理"];
    
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:YES];
    [MobClick endLogPageView:@"密码管理"];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return _titleArray.count;
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{



    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    
    if (!cell) {
        
        
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
               cell.textLabel.frame = CGRectMake(10, 0, 150, 40);

        
        cell.textLabel.font=[UIFont systemFontOfSize:15];
        
    }
    
     cell.textLabel.text = _titleArray[indexPath.section];
    return cell;

}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;{
    
    
    if (indexPath.section == 0) {
        
        [self shoushi];
        
    }else if(indexPath.section == 1){
        
        
        
        YPForgotPasswordViewController * setPassWordVC = [[YPForgotPasswordViewController alloc]init];
        
        setPassWordVC.isSetPassword=YES;
        
        setPassWordVC.title=@"修改登录密码";
        
        setPassWordVC.popVC=^{
            
            [self.navigationController popViewControllerAnimated:YES];
            
            
        };
        
        [self.navigationController pushViewController:setPassWordVC animated:YES];

    }else{
        
        YPGoWebView(String_Connect(CMD_SETTING_PAY_PSD, @"&token", TOKEN), self.navigationController);
    }
    
    
    
}

- (void)shoushi {

    if ([CLLockVC hasPwd]) {
        [CLLockVC showModifyLockVCInVC:self successBlock:^(CLLockVC *lockVC, NSString *pwd) {
            
            [lockVC dismiss:1.0f];
        }];
        
    }else{
        [CLLockVC showSettingLockVCInVC:self ishome:YES successBlock:^(CLLockVC *lockVC, NSString *pwd) {
            [lockVC dismiss:1.0f];
            
        }];
    }

    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
